import React from 'react';
import copy from 'copy-to-clipboard';
import { Button, message } from 'antd';

export default function CopyToClipboard(props) {
  const copyNow = () => {
    copy(props.text, {
      debug: true,
      message: 'Press #{key} to copy'
    });
    message.success('复制成功');
  };

  return (
    <Button type='link' onClick={copyNow}>
      复制
    </Button>
  );
}
